<!-- 房屋审核 -->
<template>
	<view>
		<view>
			<view class="bg-white" v-if="roomDetail.housebindstate === 2">
				<view class="cu-steps">
					<view class="cu-item" :class="index>active?'':'text-green'" v-for="(item,index) in steps"
						:key="index">
						<text :class="'cuIcon-' + item.cuIcon"></text> {{item.name}}
					</view>
				</view>
			</view>
			<view class="block__title">房屋信息</view>
			<view class="cu-form-group">
				<view class="title">房屋ID</view>
				{{roomDetail.roomId}}
			</view>
			<view class="cu-form-group">
				<view class="title">楼栋</view>
				{{roomDetail.floorNum}}号楼
			</view>
			<view class="cu-form-group">
				<view class="title">单元</view>
				{{roomDetail.unitNum}}单元
			</view>
			<view class="cu-form-group">
				<view class="title">房屋编号</view>
				{{roomDetail.roomNum}}室
			</view>

			<view class="cu-form-group">
				<view class="title">楼层</view>
				{{roomDetail.layer+'层'}}
			</view>
			<view class="cu-form-group">
				<view class="title">户型</view>
				{{roomDetail.housebindstate}}
			</view>
			<view class="cu-form-group">
				<view class="title">建筑面积</view>
				{{roomDetail.builtUpArea+'平方米'}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋状态</view>
				<view class="" v-if="roomDetail.housebindstate == 2">
					审核中
				</view>
				<view class="" v-else>
					已绑定
				</view>
			</view>
			<view class="bottomRegion" v-if="roomDetail.housebindstate === 2">
				<view class="vacantHouse">
					<button @click="houseUnbundling" type="warn">取消审核</button>
				</view>
			</view>
			<view class="bottomRegion" v-else>
<!-- 				<view class="vacantHouse">
					<button @click="vacantHouse" type="primary">空置房申请</button>
				</view> -->
				<view class="removeBind">
					<button @click="houseUnbundling" type="warn">解除房屋绑定</button>
				</view>
			</view>


			<view class="cu-modal" :class="delOwnerMemberFlag==true?'show':''">
				<view class="cu-dialog">
					<view class="cu-bar bg-white justify-end">
						<view class="content">温馨提示</view>
						<view class="action" @tap="_cancleCall()">
							<text class="cuIcon-close text-red"></text>
						</view>
					</view>
					<view class="padding-xl">
						您确认解除该成员房屋绑定？
					</view>
					<view class="cu-bar bg-white justify-end">
						<view class="action margin-0 flex-sub  solid-left" @tap="_cancleDeleteOwnerMember()">取消</view>
						<view class="action margin-0 flex-sub text-green solid-left" @tap="_doDeleteOwnerMember()">确认
						</view>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	// pages/my/myHouseDetail.js
	import context from '../../lib/java110/Java110Context.js';
	const factory = context.factory;

	export default {
		data() {
			return {
				delOwnerMemberFlag: false, //解除房屋绑定弹窗
				steps: [{
					cuIcon: 'usefullfill',
					name: '申请',
					desc: ''
				}, {
					cuIcon: 'radioboxfill',
					name: '审核中',
					desc: ''
				}, {
					cuIcon: 'roundcheckfill',
					name: '完成',
					desc: ''
				}],
				active: 1,
				ownerInfo: {},
				// 用户信息
				userInfo: {},
				// 用户信息
				ownerFlag: false,
				// 是否有业主信息 标记 如果有为 true  没有为false
				roomDetail: {}
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			let _that = this;
			context.onLoad(options);
			_that.roomDetail = JSON.parse(options.room);
			// factory.login.checkLoginStatus(function() {
			// 	_that.userInfo = context.getUserInfo();
			// 	//_that.roomDetail = wx.getStorageSync('roomDetail');
			// }); //查询用户信息

			// _that.loadOwenrInfo();
		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			loadOwenrInfo: function() {
				let _that = this;

				context.getOwner(function(_ownerInfo) {
					console.log(_ownerInfo);

					if (_ownerInfo) {
						_that.ownerFlag = true;
						_that.ownerInfo = _ownerInfo;
					} else {
						_that.ownerFlag = false;
					}
				});
			},
			// 解除房屋绑定
			// houseUnbundling: function(item) {
			// 	this.delOwnerMemberFlag = true;
			// 	this.curOwnerMember = item;
			// },
			// _cancleDeleteOwnerMember: function(item) {
			// 	this.delOwnerMemberFlag = false;
			// },
			_doDeleteOwnerMember: function() {
				let that = this;
				this.curOwnerMember.communityId = this.communityId;
				deleteOwnerMember(this.curOwnerMember)
					.then((res) => {
						uni.showToast({
							icon: 'none',
							title: '删除成功'
						});
						that._cancleDeleteOwnerMember();
						that._initData();
					}, (err) => {
						uni.showToast({
							icon: 'none',
							title: err
						});
						that._cancleDeleteOwnerMember();
					})
			}
		}
	};
</script>
<style scoped lang="scss">
	@import "@/pagesB/my/myHouseDetail.css";

	text {
		text-align: center;
	}

	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}

	.bottomRegion {
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		.vacantHouse {
			margin: 20rpx;
			width: 50%;
			text-align: center;
			height: 60rpx;
			float: left;
			font-size: 26rpx;
			line-height: 60rpx;

			button {
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx;
			}
		}

		.removeBind {
			margin: 20rpx;
			width: 50%;
			height: 60rpx;
			float: right;
			text-align: center;
			font-size: 26rpx;
			line-height: 60rpx;

			button {
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx;
			}
		}
	}
</style>
